import org.rsbot.script.methods.Calculations;
import org.rsbot.script.methods.Camera;
import org.rsbot.script.methods.Interfaces;
import org.rsbot.script.methods.Mouse;
import org.rsbot.script.methods.NPCs;
import org.rsbot.script.methods.Objects;
import org.rsbot.script.wrappers.RSInterface;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSTile;

public class FallenSuperheater$FallenBank extends Thread
{
  public int BANK_IFACE = 762;
  public int[] BANKERS = { 44, 45, 494, 495, 499, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948, 9710, 14367 };

  public int[] BANK_BOOTHS = { 2213, 4483, 6084, 11402, 11758, 12759, 14367, 19230, 24914, 25808, 26972, 27663, 29085, 34752, 35647, 36786 };

  public int[] BANK_CHESTS = { 4483, 12308, 21301, 27663, 42192 };

  public FallenSuperheater$FallenBank(FallenSuperheater paramFallenSuperheater) {  }

  public boolean waitToOpen() { int i = this.this$0.random(2000, 3000);
    long l = System.currentTimeMillis();
    while (System.currentTimeMillis() - l < i) {
      if (FallenSuperheater.access$000(this.this$0).get(this.BANK_IFACE).isValid())
        return true;
      try
      {
        sleep(this.this$0.random(50, 100));
      } catch (InterruptedException localInterruptedException) {
        localInterruptedException.printStackTrace();
      }
    }
    return false; }

  public RSNPC nearest(int[] paramArrayOfInt)
  {
    RSNPC[] arrayOfRSNPC1 = FallenSuperheater.access$100(this.this$0).getAll();
    int i = 99;
    Object localObject = null;
    for (RSNPC localRSNPC : arrayOfRSNPC1) {
      for (int i1 : paramArrayOfInt) {
        if (localRSNPC.getID() == i1) {
          int i2 = FallenSuperheater.access$200(this.this$0).distanceTo(localRSNPC.getLocation());
          if (i2 < i) {
            localObject = localRSNPC;
            i = i2;
          }
        }
      }
    }
    return localObject;
  }

  public boolean click(RSTile paramRSTile, int[] paramArrayOfInt) {
    FallenSuperheater.access$400(this.this$0).move(FallenSuperheater.access$300(this.this$0).tileToScreen(paramRSTile, 0.5D, 0.5D, 50));
    try {
      sleep(this.this$0.random(0, 100));
    } catch (InterruptedException localInterruptedException) {
      localInterruptedException.printStackTrace();
    }
    for (int k : paramArrayOfInt) {
      if (FallenSuperheater.access$500(this.this$0).getTopAt(paramRSTile).getID() == k) {
        FallenSuperheater.access$600(this.this$0).click(true);
        return true;
      }
    }
    return false;
  }

  public final boolean open() {
    RSObject localRSObject1 = FallenSuperheater.access$700(this.this$0).getNearest(this.BANK_CHESTS);
    RSNPC localRSNPC = nearest(this.BANKERS);
    RSObject localRSObject2 = FallenSuperheater.access$800(this.this$0).getNearest(this.BANK_BOOTHS);
    if (localRSObject1 != null) {
      if (localRSObject1.isOnScreen())
      {
        if ((click(localRSObject1.getLocation(), this.BANK_CHESTS)) || (localRSObject1.doAction("Bank Bank Chest")) || (localRSObject1.doAction("Use Bank Chest")) || (localRSObject1.doAction("Bank Chest >")))
        {
          if (waitToOpen()) {
            try {
              sleep(this.this$0.random(200, 300));
            }
            catch (InterruptedException localInterruptedException1) {
              localInterruptedException1.printStackTrace();
            }
            return true;
          }
        }
      }
      else FallenSuperheater.access$900(this.this$0).turnTo(localRSObject1.getLocation());
    }
    else if (localRSNPC != null) {
      if (localRSNPC.isOnScreen()) {
        if ((localRSNPC.doAction("Bank Banker")) && 
          (waitToOpen())) {
          try {
            sleep(this.this$0.random(200, 300));
          }
          catch (InterruptedException localInterruptedException2) {
            localInterruptedException2.printStackTrace();
          }
          return true;
        }
      }
      else
        FallenSuperheater.access$1000(this.this$0).turnTo(localRSNPC.getLocation());
    }
    else if (localRSObject2 != null) {
      if (localRSObject2.isOnScreen()) {
        if ((localRSObject2.doAction("Use-quickly Bank booth")) && 
          (waitToOpen())) {
          try {
            sleep(this.this$0.random(200, 300));
          }
          catch (InterruptedException localInterruptedException3) {
            localInterruptedException3.printStackTrace();
          }
          return true;
        }
      }
      else
        FallenSuperheater.access$1100(this.this$0).turnTo(localRSObject2.getLocation());
    }
    else {
      return false;
    }
    return false;
  }
}